package com.lc.pianostudent.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.lc.pianostudent.R;
import com.zcx.helper.dialog.AppDialog;

/**
 * Created by Administrator on 2017/8/12.
 */

public abstract class DelectDialog extends AppDialog {
    private int layoutResId;
    public DelectDialog(Context context, int layoutResId) {

        super(context, R.style.TradeDialog);
        this.layoutResId = layoutResId;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(layoutResId);

        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        window .setGravity(Gravity.CENTER);
        lp.dimAmount = 0.2f;
        window .setAttributes(lp);

        this.setCanceledOnTouchOutside(true);
        View.OnClickListener listener = new View.OnClickListener() {

            @Override
            public void onClick(View view) {

                switch (view.getId()) {

                    case R.id.cancel:

                        cancel();

                        break;

                    case R.id.queding:

                        confirm();

                        break;

                }

                dismiss();

            }

        };

        findViewById(R.id.cancel).setOnClickListener(listener);

        findViewById(R.id.queding).setOnClickListener(listener);

    }

    public abstract void cancel();
    public abstract void confirm();

}
